{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# QCoDeS Example with the Rigol DG 1062 Instrument" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import time\n", "\n", "from qcodes.instrument_drivers.rigol import RigolDG1062" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Instantiate the driver " ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Connected to: Rigol Technologies DG1062Z (serial:DG1ZA195006397, firmware:03.01.12) in 0.18s\n" ] } ], "source": [ "gd = RigolDG1062(\"gd\", \"TCPIP0::169.254.187.99::INSTR\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Basic usage" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Accessing the channels" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gd.channels[0]\n", "# Or...\n", "gd.ch1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Trun the output for channel 1 to \"on\"" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "gd.channels[0].state(1)\n", "# This is idential to\n", "gd.ch1.state(1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "With `apply` we can check which waveform is being generated now, for example on channel 1" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'waveform': 'SIN', 'freq': 1000.0, 'ampl': 1.0, 'offset': 0.0, 'phase': 0.0}" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gd.channels[0].current_waveform()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can also change the waveform " ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "gd.channels[0].apply(waveform=\"SIN\", freq=2000, ampl=0.5, offset=0.0, phase=0.0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Change individual settings like so: " ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "gd.channels[0].offset(0.1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This works for every setting, except waveform, which is read-only" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'SIN'" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gd.channels[0].waveform()" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "We cannot set a waveform like this \n" ] } ], "source": [ "try:\n", " gd.channels[0].waveform(\"SIN\")\n", "except NotImplementedError:\n", " print(\"We cannot set a waveform like this \")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can however do this: " ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "gd.channels[0].sin(freq=1E3, ampl=1.0, offset=0, phase=0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To find out which arguments are applicable to a waveform: " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Find out which waveforms are available" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['HARM', 'NOIS', 'RAMP', 'SIN', 'SQU', 'TRI', 'USER', 'DC', 'ARB']\n" ] } ], "source": [ "print(gd.waveforms)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setting the impedance " ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "gd.channels[1].impedance(50)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "50.0" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gd.channels[1].impedance()" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "gd.channels[1].impedance(\"HighZ\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Alternatively, we can do \n", "\n", "```python\n", "gd.channels[1].impedance(\"INF\")\n", "```" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'HighZ'" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gd.channels[1].impedance()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Sync commands " ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'ON'" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gd.channels[0].sync()" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "gd.channels[0].sync(\"OFF\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Alternativly we can do \n", "\n", "```python\n", "gd.channels[0].sync(0) \n", "```" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'OFF'" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gd.channels[0].sync()" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "gd.channels[0].sync(1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Alternativly we can do\n", "\n", "```python\n", "gd.channels[0].sync(\"ON\")\n", "```" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'ON'" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gd.channels[0].sync()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Burst commands " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Internally triggered burst " ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "# Interal triggering only works if the trigger source is manual\n", "gd.channels[0].burst.source(\"MAN\")" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "# The number of cycles is infinite\n", "gd.channels[0].burst.mode(\"INF\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If we want a finite number of cycles: \n", "\n", "```python\n", "gd.channels[0].burst.mode(\"TRIG\")\n", "gd.channels[0].burst.ncycles(10000)\n", "```\n", "\n", "Setting a period for each cycle: \n", "\n", "```python\n", "gd.channels[0].burst.period(1E-3)\n", "```" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "# Put channel 1 in burst mode\n", "gd.channels[0].burst.on(1)\n", "# Turn on the channel. For some reason, if we turn on the channel\n", "# immediately after turning on the burst, we trigger immediately.\n", "time.sleep(0.1)\n", "gd.channels[0].state(1)" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "# Finally, trigger the AWG\n", "gd.channels[0].burst.trigger()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### extranally triggered burst " ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [], "source": [ "gd.channels[0].burst.source(\"EXT\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Setting the idle level" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [], "source": [ "# Set the idle level to First PoinT\n", "gd.channels[0].burst.idle(\"FPT\")" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [], "source": [ "# We can also give a number\n", "gd.channels[0].burst.idle(0)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.6" }, "nbsphinx": { "execute": "never" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }